home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Deutsche Edition 1
/
Deutsche Edition 1.iso
/
amok
/
amok_lha
/
amok22.lha
/
Stardance
/
StarDance.MOD
< prev
next >
Wrap
Text File
|
1993-08-15
|
7KB
|
288 lines
(*******************************************************************************
:Program. StarDance.MOD
:Author. André Theiler und Carsten Wartmann
:Address. Wutzkyallee 83, D-1000 Berlin 47 (C.W.)
:Phone. 030/6614776
:Version. 1.5 (1.0)
:Date. 6/89 (4/89)
:Copyright. PD
:Language. Modula-2
:Compiler. M2Amiga V3.2d
:Contents. Simulation des Sonnensystems
*******************************************************************************)
(* For more info see StarDance.DOC *)
MODULE StarDance ;
FROM SYSTEM IMPORT BITSET,ADR,FFP,ADDRESS,INLINE ;
FROM Arts IMPORT Assert ;
FROM Intuition IMPORT NewScreen,ScreenPtr,OpenScreen,CloseScreen,
customScreen,NewWindow,WindowPtr,
IDCMPFlags,IDCMPFlagSet,WindowFlags,WindowFlagSet,
OpenWindow,CloseWindow ;
FROM Graphics IMPORT ViewModes,ViewModeSet,SetAPen,RastPortPtr,ClearScreen,
SetRGB4,AreaMove,AreaDraw,AreaEnd,AllocRaster,Move,
FreeRaster,InitArea,TmpRas,AreaInfo,InitTmpRas,
RastPort,LoadRGB4,WritePixel,Draw ;
FROM MathLib0 IMPORT sqrt ;
FROM FileSystem IMPORT File,Response,Lookup,Close,ReadChar ;
FROM Str IMPORT Concat ;
FROM RealConversions IMPORT StrToReal ;
VAR screen : NewScreen ;
screenptr : ScreenPtr ;
window : NewWindow ;
windowptr : WindowPtr ;
drawRP : RastPortPtr ;
viewP : ADDRESS ;
cia[0BFE000H] : BITSET ;
sternmax : INTEGER ;
zoom,deltat,f : REAL ;
x,y,z,masse,
vx,vy,vz : ARRAY [0..20] OF REAL ;
PROCEDURE RGB ; (*$E-*)
BEGIN (* Farbwerte der Objekte *)
INLINE(
0000H,0F00H,0F80H,0FF0H,000FH,0F0FH,00FFH,00F0H,
0FFFH,0777H,0F50H,05F0H,04C0H,03D0H,02E0H,01F0H
) ;
END RGB ;
PROCEDURE ExtData() ;
VAR data : File ;
stern : INTEGER ;
wert : REAL ;
zeichen : CHAR ;
zahlstr : ARRAY [0..30] OF CHAR ;
einstr : ARRAY [0..1] OF CHAR ;
err,ende : BOOLEAN ;
PROCEDURE ReadData() : REAL ;
BEGIN (* Lesen eines Wertes *)
LOOP
ReadChar(data,zeichen) ;
IF data.eof OR (data.res # done) THEN
ende := TRUE ;
RETURN (1.0);
END ;
IF (zeichen = "#") THEN
EXIT ;
END ;
END (*LOOP*) ;
zahlstr := "" ;
einstr := " " ;
ReadChar(data,zeichen) ;
REPEAT
einstr[0] := zeichen ;
Concat(zahlstr,einstr) ;
ReadChar(data,zeichen) ;
UNTIL (zeichen = "!") ;
StrToReal(zahlstr,wert,err) ;
Assert(err#TRUE,ADR("Syntax Error im Datenfile !")) ;
RETURN(wert) ;
END ReadData ;
BEGIN (* ExtData *)
Lookup(data,"StarDance.DAT",1024,FALSE) ;
Assert(data.res=done,ADR("Lookup misslungen")) ;
sternmax := TRUNC(ReadData()) ;
f := ReadData() ;
zoom := ReadData() ;
deltat := ReadData() ;
stern := 0 ;
WHILE (stern < sternmax) AND (ende = FALSE) DO
x[stern] := ReadData() ;
y[stern] := ReadData() ;
z[stern] := ReadData() ;
vx[stern] := ReadData() ;
vy[stern] := ReadData() ;
vz[stern] := ReadData() ;
masse[stern] := ReadData() ;
IF (ReadData()#0.0) THEN
INC(stern) ;
ELSE
DEC(sternmax) ;
END ;
END (*WHILE*) ;
Close(data) ;
END ExtData ;
PROCEDURE OpenAll ;
BEGIN (* Öffnen des Screens und Windows *)
WITH screen DO
leftEdge := 0 ;
topEdge := 0 ;
width := 640 ;
height := 256 ;
depth := 4 ;
viewModes := ViewModeSet{hires} ;
type := customScreen ;
font := NIL ;
defaultTitle := NIL ;
gadgets := NIL ;
customBitMap := NIL ;
END (*WITH*) ;
screenptr := OpenScreen(screen) ;
Assert(screenptr # NIL,ADR("Screen is nix")) ;
WITH window DO
leftEdge := 0 ;
topEdge := 0 ;
width := 640 ;
height := 256 ;
detailPen := 0 ;
blockPen := 1 ;
idcmpFlags := IDCMPFlagSet{} ;
flags := WindowFlagSet{borderless} ;
firstGadget := NIL ;
checkMark := NIL ;
title := NIL ;
screen := screenptr ;
bitMap := NIL ;
type := customScreen ;
END (*WITH*) ;
windowptr := OpenWindow(window) ;
Assert(windowptr # NIL,ADR("Window is nix")) ;
drawRP := windowptr^.rPort ;
viewP := ADR(screenptr^.viewPort) ;
LoadRGB4(viewP,ADR(RGB),16) ;
END OpenAll ;
PROCEDURE Dance ;
VAR stern0,stern1,
xbild,ybild,
dummy : INTEGER ;
ax,ay,az,
dx,dy,dz,
distanz,a : REAL ;
BEGIN (* Eigentliche Berechnung *)
WHILE (7 IN cia) DO (* Solange bis Joy-Knopf gedrückt *)
stern0 := 0 ;
WHILE (stern0 < sternmax) DO
ax := 0.0 ;
ay := 0.0 ;
az := 0.0 ;
stern1 := 0 ;
WHILE (stern1 < sternmax) DO
IF (stern0 # stern1) THEN
dx := x[stern1] - x[stern0] ;
dy := y[stern1] - y[stern0] ;
dz := z[stern1] - z[stern0] ;
distanz := sqrt(dx*dx + dy*dy + dz*dz) ;
a := f * masse[stern1] / (distanz*distanz) ;
ax := ax + dx * a / distanz ;
ay := ay + dy * a / distanz ;
az := az + dz * a / distanz ;
END (*IF*) ;
INC(stern1) ;
END (*WHILE stern1*) ;
vx[stern0] := vx[stern0] + ax * deltat ;
vy[stern0] := vy[stern0] + ay * deltat ;
vz[stern0] := vz[stern0] + az * deltat ;
x[stern0] := x[stern0] + vx[stern0] * deltat ;
y[stern0] := y[stern0] + vy[stern0] * deltat ;
z[stern0] := z[stern0] + vz[stern0] * deltat ;
xbild := 320 + TRUNC(x[stern0] * zoom*2.0) ;
ybild := 120 - TRUNC(y[stern0] * zoom) ;
SetAPen(drawRP,stern0+1) ;
dummy := WritePixel(drawRP,xbild,ybild) ;
INC(stern0) ;
END (*WHILE stern0*) ;
END (*WHILE CIA*) ;
END Dance ;
BEGIN (* Hauptprogramm StarDance *)
OpenAll ;
ExtData ;
Dance ;
WHILE (6 IN cia) DO (* Bild ansehen bis Mausknopf gedrückt...*)
END (*WHILE*) ;
CloseWindow(windowptr) ; (* Alles zu *)
CloseScreen(screenptr) ;
END StarDance .